import { onMounted, ref } from 'vue'

import { authApi } from '@/apis'

export function useCaptcha() {
  const captcha = ref({
    id: '',
    imageBase64: ''
  } as IGetCaptchaRes)

  async function handleGetCaptcha() {
    captcha.value = await authApi.getCaptcha()
  }

  onMounted(() => {
    handleGetCaptcha()
  })

  return {
    captcha,
    handleGetCaptcha
  }
}
